import unittest
import channels
import cStringIO

class ChannelsTestCase(unittest.TestCase):
	def testChannelRead(self):
		buf = cStringIO.StringIO()
		buf.write("\nSBS HD:592500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:102:103:816\n\n")
		buf.seek(0)
		c = channels.Channels()
		c.read(buf)
		self.failUnless(c.has_key("SBS HD"))
		self.failIf(c.has_key("NONEXISTANT"))
		print c.get_vpid("SBS HD")
		print c.get_parameter("SBS HD")
		self.failUnless(c.get_vpid("SBS HD") == 102)
		self.failUnless(c.get_apid("SBS HD") == 103)

def suite():
	return unittest.makeSuite(ChannelsTestCase)


if __name__ == '__main__':
	# When this module is executed from the command-line, run all its tests
	unittest.TextTestRunner().run(suite())

